package com.zhihao.zhihaopicturebackend.model.enums;

import lombok.Getter;

/**
 * @author Jackson
 * @create 2024/12/23 19:23
 * @description 图片格式枚举类
 */
@Getter
public enum PictureFormatEnum {

    JPEG("jpeg"),
    JPG("jpg"),
    PNG("png"),
    WEBP("webp");

    private final String pictureFormat;

    PictureFormatEnum(String pictureFormat) {
        this.pictureFormat = pictureFormat;
    }

    // 根据文件后缀名判断是否是有效的图片格式
    public static boolean isValidFormat(String fileSuffix) {
        for (PictureFormatEnum imageFormat : values()) {
            if (imageFormat.getPictureFormat().equalsIgnoreCase(fileSuffix)) {
                return true;
            }
        }
        return false;
    }
}

